<?php 
include './functions.php';
function upLoad(){
//	p($_FILES);
	if(IS_POST){
		foreach ($_FILES['up']['tmp_name'] as $k=> $v) {
			$a = $_FILES['up']['tmp_name'][$k];
			if(is_uploaded_file($a)){
				$type = ltrim(strrchr($_FILES['up']['name'][$k], '.'),'.');
				$fileName = time().mt_rand(0, 9999) . '.' . $type;
				$path = './a/' . date('ymd');
				is_dir($path) || mkdir($path,0777,true);
				$fullPath = $path . '/' . $fileName;
				move_uploaded_file($a, $fullPath);
			}
		}
		success('上传成功', './upload.php');
	}
}
upLoad();
 ?>
 <!doctype html>
 <html lang="en">
 <head>
 	<meta charset="UTF-8" />
 	<title>Document</title>
 	<link rel="stylesheet" type="text/css" href="css/animate.css"/>
 	<style type="text/css">
 		*{
 			padding: 0;
 			margin: 0;
 		}
 		body{
 			/*background: #dbdbdb;*/
 		}
 		#show{
 			width: 100%;
 		}
 		.nav{
 			width: 100%;
 			height: 50px;
 			line-height: 50px;
 			font-weight: 800;
 			color: #fff;
 			background: lightblue;
 			text-align: center;
 		}
 		.content{
 			overflow: hidden;
 			box-sizing: border-box;
 			width: 1200px;
 			margin: 20px auto;
 		}
 		.block{
 			float: left;
 			margin: 20px 20px;
 			width: 250px;
 			background: #dbdbdb;
 			height: 200px;
 			border-radius: 5px;
 			overflow: hidden;
 		}
 		.block img{
 			width: 250px;
 			height: 150px;
 		}
 		.bottom{
 			width: 100%;
 			height: 50px;
 			line-height: 50px;
 			text-indent: 20px;
 		}
 	</style>
 </head>
 <body>
 	<form action="" method="post"enctype="multipart/form-data">
 		<input type="file" name="up[]" multiple="multiple"/>
 		<input type="submit" value="上传"/>
 	</form>
 	<div id="show">
 		<div class="nav">相册</div>
 		<div class="content">
 			<?php $arr = array('tada', 'wobble', 'fadeInUp'); ?>
 			<?php foreach  (glob('./a/'.date('ymd').'/*') as $k => $v) { ?>
 			<div class="block animated <?php echo $arr[mt_rand(0, 2)]; ?>">
 				<div class="con-top">
 					<img src="<?php echo $v;?>"/>
 				</div>
 				<div class="bottom">
 					<?php echo basename($v);  ?>
 				</div>
 			</div>
 			<?php }  ?>
 		</div>
 	</div>
 </body>
 </html>